package com.paopao.common.util;
import org.apache.shiro.codec.Base64;
import org.apache.shiro.crypto.hash.Md5Hash;
public class CryptographyUtil  
{
	//加密
	public static String entoBase64(String str){
		String base64Encoded = Base64.encodeToString(str.getBytes());
		return base64Encoded;  
	}
	//解密
	public static String dstoString(String str){
		String str2 = Base64.decodeToString(str);
		return str2;
	}
	
	//加盐  md5加密
	public static String md5(String str,String salt){
		String md5 = new Md5Hash(str, salt).toString();
		return md5;
	}
	public static void main(String[] args)
	{
		String passWord="hp";
		String passWord1="ceshi";
		String passWord2="admin";
		String passWord3="tom";
		System.out.println("===加密===");
		System.out.println("加密"+entoBase64(passWord));
		System.out.println("===解密===");
		System.out.println("解密"+dstoString("MTIzNDU2"));
		System.out.println("===md5加密===");
		System.out.println("md5加密  0"+md5(passWord,"111"));
		System.out.println("md5加密  1 "+md5(passWord1,"111"));
		System.out.println("md5加密  2"+md5(passWord2,"111"));
		System.out.println("md5加密  3"+md5(passWord3,"111"));
		
	}
	
}
